<?php

class Db_Tables2_BDictProductInvoiceVersion
{
	function __construct() {
		$this->dealers_db = Zend_Registry::get("dealers_db");
	}
	
	function MakeArr()
	{
		$result = array();
		
		$select = $this->dealers_db->select();
		$select->from("b_dict_product_invoice_version", "*");
		$select->where("status = ?", 1);
		$select->order(array("product_id", "sequence"));
		
		$data = $this->dealers_db->fetchAll($select);
		
		if(!empty($data))
		{
			foreach($data as $d)
			{
				if(!isset($result[$d['product_id']]))
				{
					$result[$d['product_id']] = array();
				}
				
				$result[$d['product_id']][$d['id']] = $d['invoice_version'];
			}
		}
		
		return $result;
	}
	
	function FetchAll()
	{
		$result = array();
		
		$select = $this->dealers_db->select();
		$select->from("b_dict_product_invoice_version", "*");
		$select->where("status = ?", 1);
		$select->order(array("product_id", "sequence"));
		
		$data = $this->dealers_db->fetchAll($select);
		
		if(!empty($data))
		{
			foreach($data as $d)
			{
				$result[$d['id']] = $d['invoice_version'];
			}
		}
		
		return $result;
	}
}